<?= \common\widgets\Asset::widget(['type'=>['viewer']])?>
<div style="display: flex">
    <?=$this->params['leftHtml']?>
    <div  style="width: 89.7%">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>评价时间： </label>
                            <?= \common\widgets\FormInput::widget(['name'=>'input','extend'=>['name'=>'between[create_time][start]','id'=>'startTime','place'=>'开始时间']])?>
                            <span>-</span>
                            <?= \common\widgets\FormInput::widget(['name'=>'input','extend'=>['name'=>'between[create_time][end]','id'=>'endTime','place'=>'结束时间']])?>
                        </li>
                        <li><?= \common\widgets\FormInput::widget(['name'=>'select|状态','extend'=>['name'=>'where[status]','value'=>'','place'=>'所有','data'=>$this->params['statusAll']]])?></li>
                        <li>
                            <?= $this->render('/iframe',['name'=>'searchbtn|搜索'])?>
                            <?= $this->render('/iframe',['name'=>'resetbtn|重置'])?>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<?php $this->beginBlock('script'); ?>
<script>
    $(function () {
        var statusAll = eval(<?=json_encode($this->params['statusAll'])?>)
        bootUrl.url = "<?=\yii\helpers\Url::to(['order/comment'])?>"
        var options = {
            modalName: "售后订单",
            detailUrl: bootUrl.detailUrl,
            columns: [
                {field: 'id', title: 'ID'},
                {
                    field: 'goods_html',
                    title: '商品信息',
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '订单信息',
                    field: 'order_html',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '用户信息',
                    field: 'user_html',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '内容',
                    field: 'content',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '物流服务',
                    field: 'logistics_star',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return value+'星';
                    }
                },
                {
                    title: '服务态度',
                    field: 'service_attitude',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return value+'星';
                    }
                },
                {
                    title: '状态',
                    field: 'status',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.view.statusShow(row,false,statusAll);
                    }
                },
                {field: 'create_time', title: '评论时间'},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var html = `<a class="btn btn-success btn-xs" href="javascript:;" onclick="detail(${row.order_id})"><i class="fa fa-eye"></i>查看订单</a>`;
                        if (row.status==0){
                            html += ` <a class="btn btn-info btn-xs" href="javascript:;" onclick="deliver(${row.id})">审核</a>`
                        }
                        return html;
                    }
                }
            ],
            onPostBody:function (data) {
                for (let i = 0; i < data.length; i++) {
                    new Viewer(document.getElementById('good_'+data[i].id),{navbar:false,title:false});
                }
            }
        };
        $.table.init(options);
    });
    function detail(id) {
        var offsetWidth = document.body.offsetWidth-100
        var clientHeight = document.body.clientHeight-100
        $.operate.detail(id,offsetWidth,clientHeight)
    }
    function deliver(id) {
        $.modal.open("审核", '<?=\yii\helpers\Url::to(['comment-review'])?>?id='+id,'80','80',null,'%');
    }
</script>
<?php $this->endBlock(); ?>

